<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/style/css/pageCommon.css" />
<script language="javascript" src="${pageContext.request.contextPath}/script/jquery.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/script/commonUtils.js" charset="utf-8"></script>
<%-- <script language="javascript" src="${pageContext.request.contextPath}/script/user.js" charset="utf-8"></script> --%>
</head>
<script type="text/javascript" async="async">

var sessionId = '${sessionId}';
var memberId = '${memberId}';
var page;
var pageNum=1;
var pageSize=20;

$(function(){
	$("input[name='memberId']").val(memberId);
	var pNum=$("input[name='pageNum']").val();
	pageNum=pNum==""?pageNum:pNum;
	search(pageNum);
});

function search(pageNum){
	var goodsId=$("input[name='goodsId']").val();
	var keyword=$("input[name='keyword']").val();
	var memberId=$("input[name='memberId']").val();
	var mobile=$("input[name='mobile']").val();
	var wechat=$("input[name='wechat']").val();
	var param={
			goodsId:goodsId,
			memberId:memberId,
			mobile:mobile,
			wechat:wechat,
			keyword:keyword,
			pageNum:pageNum,
			pageSize:pageSize,
			"method":"queryGoodsList"};
	var url="${pageContext.request.contextPath}/common/commonController?sessionId="+sessionId;
	$.ajax({
	    url : url,
	    type : "POST",
	    async : true,
	    contentType: "application/json; charset=utf-8",
	    data : JSON.stringify(param),
	    dataType : 'json',
	    success : function(data) {
	    	if(data.resultCode=="000000"){
	    		loadPageBar(data);
	    		$("#TableData").html("");
	    		$.each(data.data.list,function(n,v){
	    			var tfont=$("#table").find("tfoot").clone();
	    			var goodsId=v["id"];
	    			var memberId=v["memberId"];
	    			tfont.find("label[name='goodsId']").text(goodsId);
// 	    			tfont.find("label[name='memberId']").text(v["memberId"]);
	    			tfont.find("label[name='nickName']").text(v["nickName"]);
	    			tfont.find("label[name='categoryName']").text(v["categoryName"]);
	    			tfont.find("label[name='price']").text(v["price"]);
	    			tfont.find("label[name='address']").text(v["address"]);
	    			tfont.find("label[name='wechat']").text(v["wechat"]);
	    			tfont.find("label[name='mobile']").text(v["mobile"]);
	    			tfont.find("label[name='lookupNum']").text(v["lookupNum"]);
	    			tfont.find("label[name='collectNum']").text(v["collectNum"]);
	    			tfont.find("label[name='subscribeDesc']").text(v.memberSubscribe["subscribeDesc"]);
	    			tfont.find("label[name='isPayPlatformDesc']").text(v["isPayPlatformDesc"]);
	    			tfont.find("label[name='statusDesc']").text(v["statusDesc"]);
	    			tfont.find("label[name='updatedAt']").text(v["updatedAt"]);
	    			tfont.find("label[name='createTime']").text(v["createTime"]);
	    			var hrefInfo="${pageContext.request.contextPath}/page/operateList?preffix=member&sessionId="+sessionId+"&memberId=";
	    			tfont.find("a[name='operateList']").attr("href",hrefInfo+memberId);
	    			var hrefInfo="${pageContext.request.contextPath}/page/sessionList?preffix=member&sessionId="+sessionId+"&goodsId=";
	    			tfont.find("a[name='sessionList']").attr("href",hrefInfo+goodsId);
	    			$("#TableData").append(tfont.html());
	    		});
	    	}else{
	    		alert(data.resultMsg)
	    	}
	    }
	});
}


function robotMsg(obj){
	var goodsId=$(obj).parent().parent().find("label[name='goodsId']").text();
	var param={
			goodsId:goodsId,
			"method":"robotMsg"};
	var url="${pageContext.request.contextPath}/common/commonController?sessionId="+sessionId;
	$.ajax({
	    url : url,
	    type : "POST",
	    async : true,
	    contentType: "application/json; charset=utf-8",
	    data : JSON.stringify(param),
	    dataType : 'json',
	    success : function(data) {
	    	if(data.resultCode=="000000"){
	    		alert("发送成功");
	    	}else{
	    		alert(data.resultMsg)
	    	}
	    }
	});
}

</script>
<body>

	<div id="Title_bar">
		<div id="Title_bar_Head">
			<div id="Title_Head"></div>
			<div id="Title">
				<input type="image" border="0" width="13" height="13"
					src="${pageContext.request.contextPath}/style/images/title_arrow.gif" />
					goods查询
			</div>
			<div id="Title_End"></div>
		</div>
	</div>

<div id=MainArea>
<div style="padding-left: 10px;">
         <div class="ItemBlock_Title1">
         	查询条件
         </div>
		<div class="ItemBlockBorder">
			<div class="ItemBlock">
				<table cellpadding="0" cellspacing="0" class="mainForm">
					<tr>
						<td>goodsId&nbsp;&nbsp;<input type="text" name="goodsId" /></td>
						<td>会员号&nbsp;&nbsp;<input type="text" name="memberId" /></td>
						<td>关键字&nbsp;&nbsp;<input type="text" name="keyword" /></td>
					</tr>
					<tr>
						<td>手机号&nbsp;&nbsp;<input type="text" name="mobile" /></td>
						<td>微信号&nbsp;&nbsp;<input type="text" name="wechat" /></td>
						<td>
							 <div id="InputDetailBar" style="float: left"> 
					            <input type="image" src="${pageContext.request.contextPath}/style/images/button/query.PNG"  onclick="search(1)" />
					        </div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		
		<table id="table" border="0" cellspacing="0" cellpadding="0" style="margin-top: 0px;width:98%" class="TableStyle">
		<div class="ItemBlock_Title1">
			查询结果
         </div>
			<thead>
				<tr align=center valign=middle id=TableTitle>
					<td >goodsId</td> 
<!-- 					<td >memberId</td>  -->
					<td >昵称</td> 
					<td >分类</td> 
					<td >价格</td> 
					<td >地址</td>
					<td >微信号</td>
					<td >手机号</td>
					<td >浏览数</td>
					<td >收藏数</td>
					<td >关注</td>
					<td >状态</td>
					<td >平台支付</td>
					<td >置顶时间</td>
					<td >创建时间</td>
					<td >操作</td>
				</tr>
			</thead>
			<tbody id="TableData" class="dataContainer" datakey="userList">

			</tbody>
			<tfoot class="TableDetail1 template" style="display:none">
				<tr class="TableDetail1 template" align="center"  style="display:run-in">
					<td><label name="goodsId"></label></td>
<!-- 					<td><label name="memberId"></label></td> -->
					<td><label name="nickName"></label></td>
					<td><label name="categoryName"></label></td>
					<td><label name="price"></label></td>
					<td><label name="address"></label></td>
					<td><label name="wechat"></label></td>
					<td><label name="mobile"></label></td>
					<td><label name="lookupNum"></label></td>
					<td><label name="collectNum"></label></td>
				    <td><label name="subscribeDesc"></label></td>
				    <td><label name="statusDesc"></label></td>
				    <td><label name="isPayPlatformDesc"></label></td>
					<td><label name="updatedAt"></label></td>
					<td><label name="createTime"></label></td>
					<td> 
						<a name="sendMessage" href=""  onclick="return robotMsg(this);" >发消息</a> 
						<a name="operateList" href="" >轨迹</a> 
						<a name="sessionList" href="" >会话</a> 
					</td>
				</tr>
			</tfoot>
		</table>


		<div class="ItemBlock_Title1" />
		<div>
			<div style="float: left;">
				<input type="text" name="pageNum" style="display:none"/>
				页次：<label name="pageNum" ></label>/<label name="pages" ></label>页 &nbsp;
				每页显示：<label name="pageSize" ></label>条&nbsp;总记录数：<label name="total" ></label>条&nbsp;</div>
			<input type="image" name="firstPage" src="${pageContext.request.contextPath}/style/images/btn_all_left.gif" onclick="search(this.value)" />
			<input type="image" name="prePage" src="${pageContext.request.contextPath}/style/images/btn_to_left.gif"  onclick="search(this.value)" />
			<input type="image" name="nextPage" src="${pageContext.request.contextPath}/style/images/btn_to_right.gif"  onclick="search(this.value)" />
			<input type="image" name="lastPage" src="${pageContext.request.contextPath}/style/images/btn_all_right.gif" onclick="search(this.value)"  />
		</div>
		</div>
	</div>
</body>
</html>
